{%extends "adminheader.html.twig"%}



{%block body%}
   
{% if(session.login == 'Master') %}

<div id="content1">
    <p class="big">Dodaj treści:</p><form action="{{ URL }}_SkyCMS/tresci/dodaj" name="form_dodaj" method="post" enctype="multipart/form-data">
		<input type="hidden" id="strona" name="id" value="" size="2">
        <a name="form"></a>
        <table>			
                        <tr>
				<td><p>język:</p></td>
				<td>
                                    <select name="jezyk">					
                                        <option value="pl">pl</option>
                                        <option value="eng">eng</option>
                                        <option value="ru">ru</option>
                                    </select>
				</td>
			</tr>
			<tr>
				<td><p>nazwa:</p></td>
				<td><input type="text" name="nazwa" value="" size="50"></td>
			</tr>
                        <tr>
				<td><p>widok: (<b>kontroler/metoda</b>)</p></td>
				<td><input type="text" name="template" value="" size="50"></td>
			</tr>
			<tr>
				<td><p>treść:</p></td>
				<td><textarea name="tresc" id="elm1" rows="15" cols="80" style="800px"></textarea></td>
			</tr>
			<tr>
                            <td><p>ID rodzica</p></td>
                            <td>
                                    <select name="id_rodzic">
                                        <option value="0">bez rodzica</option>
                                        {%for item in rodzice%}
                                            {%if item['seo']%}
                                            <option value="{{ item['id'] }}">{{ item['nazwa']|raw }}</option>
                                            {%endif%}
                                        {%endfor%}
                                    </select>
				</td>
                                
			</tr>
			<tr>
                            <td><p>SEO? </p></td>
                            <td><input type="checkbox" name="SEO" value="1"></td>
                                
			</tr>		
                        <tr>
				<td colspan="2" align="right">
					<input type="submit" name="submit" value="dodaj" class="button2">				</td>
			</tr>
			
		</table>
		</form>   

{%endif%}
<table cellpadding="4px"><tr>
<th width="220"><p>strona</p></th>
<th width="60"><p>jezyk</p></th>
<th width="60"><p>id</p></th>
<th width="100"><p>modyfikacja</p></th>
</tr>

{#################################### LISTA NEWSOW ####################################}
{%for news in rodzice%}

{############ SPRAWDZENIE CZY ID NEWSA JEST W UPRAWNIENIACH ############}
    {%if news['id'] in session.uprawnienia or session.poziom == 1 or session.poziom == 2%}

{############ WARUNEK DLA NEWSÓW BEZ RODZICÓW ############}
    {%if news['seo'] %}
        {%set style='font-weight:900;font-size:12pt;'%}
    {%else%}
        {%set style='font-size:12pt;'%}
    {%endif%}

        <tr class="back" style="" height="30">
            <td align="left"><p style="{{style}}">&nbsp;&nbsp;{{ news['nazwa']|raw }}</p></td>
            <td align="center"><p>{{ news['jezyk'] }}</p></td>
            <td align="center"><p>{{ news['id'] }}</p></td>
            <td align="center"><p>{{ news['data_modyfikacji'] }}</p></td>

            <td>    
                <form action="{{ URL }}_SkyCMS/tresci/edytuj/{{ news['id'] }}" name="form_edycja" method="post" enctype="multipart/form-data" style="display:inline;">
                <input type="submit" name="submit" class="button2" display:inline;" value="edytuj">
                </form>

                <form action="{{ URL }}_SkyCMS/tresci/usun/{{ news['id'] }}" name="form_usun" method="post" enctype="multipart/form-data" style="display:inline;">
                <input type="submit" name="submit" class="button2" display:inline;" onClick="return confirm(\'Czy na pewno chcesz usunąć?\')" value="usuń">
                </form>

                <form action="{{ URL }}_SkyCMS/tresci/SEO/{{ news['id'] }}" name="form_usun" method="post" enctype="multipart/form-data" style="display:inline;">
                <input type="submit" name="submit" class="button2" display:inline;" value="edytuj seo">
                </form>
            </td>
        </tr>
        
        {%for dziecko in dzieci%}
            {%if dziecko['rodzic'] == news['id']%}
        
                <tr class="back" style="background-color:white;" height="30">
                   <td><p style="text-indent:30;">- {{ dziecko['nazwa']|raw }}</p></td>
                   <td align="center"><p>{{ dziecko['jezyk'] }}</p></td>
                   <td align="center"><p>{{ dziecko['id'] }}</p></td>
                   <td align="center"><p>{{ dziecko['data_modyfikacji'] }}</p></td>

                   <td>    
                       <form action="{{ URL }}_SkyCMS/tresci/edytuj/{{ dziecko['id'] }}" name="form_edycja" method="post" enctype="multipart/form-data" style="display:inline;">
                       <input type="submit" name="submit" class="button2" display:inline;" value="edytuj">
                       </form>

                       <form action="{{ URL }}_SkyCMS/tresci/usun/{{ dziecko['id'] }}" name="form_usun" method="post" enctype="multipart/form-data" style="display:inline;">
                        <input type="submit" name="submit" class="button2" display:inline;" onClick="return confirm(\'Czy na pewno chcesz usunąć?\')" value="usuń">
                       </form>
                   </td>
                   </tr>
            {%endif%}
        {%endfor%}

    {%endif%}
{%endfor%}


</table>
</div>

{%endblock%}